/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.UserManager;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.util.Map;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class UpdateAppUserPwd extends AbstractAction
/*    */ {
/* 22 */   private static Logger logger = Logger.getLogger(UpdateAppUserPwd.class
/* 23 */     .getName());
/*    */ 
/*    */   public UpdateAppUserPwd(AbstractHttpServlet servlet)
/*    */   {
/* 26 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 33 */     User loginUser = super.getLoginUser(request);
/*    */ 
/* 35 */     String oldpwd = Util.getURLParameter(request.getParameter("oldpwd"));
/* 36 */     String newpwd = Util.getURLParameter(request.getParameter("newpwd"));
/*    */ 
/* 38 */     UserManager manager = new UserManager();
/* 39 */     Map item = null;
/*    */     try {
/* 41 */       item = manager.login(loginUser.userId, oldpwd, false);
/*    */     } catch (Exception e) {
/* 43 */       logger.warn("old password check failed", e);
/*    */     }
/*    */ 
/* 46 */     if (item == null) {
/* 47 */       super.showErrorMessage(response, "旧密码输入错误，请确认后再输入");
/* 48 */       return;
/*    */     }
/*    */ 
/*    */     try
/*    */     {
/* 53 */       int result = manager.updatePwd(loginUser.userId, newpwd);
/* 54 */       if (result <= 0) {
/* 55 */         super.showErrorMessage(response, "用户密码更新失败，请稍后再试");
/* 56 */         return;
/*    */       }
/* 58 */       super.showSuccessMessage(response);
/*    */     } catch (Exception e) {
/* 60 */       logger.warn("update user info failed", e);
/* 61 */       super.showErrorMessage(response, "用户密码更新失败，请稍后再试");
/* 62 */       return;
/*    */     }
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.UpdateAppUserPwd
 * JD-Core Version:    0.6.1
 */